import { createRouter, createWebHistory } from 'vue-router'

// 导入页面组件
import templateStyn from '@/views/templateStyn.vue'
import computed from '@/views/computed.vue'
import ifandfor from '@/views/ifandfor.vue'
import watchandwatchEffect from '@/views/watchandwatchEffect.vue'
import keepAlive from '@/views/keepAlive.vue'
import pinia from '@/views/pinia.vue'

// 定义路由
const routes = [
  {
    path: '/',
    redirect: '/template-styn'
  },
  {
    path: '/template-styn',
    name: 'templateStyn',
    component: templateStyn
  },
  {
    path: '/computed',
    name: 'computed',
    component: computed
  },
  {
    path: '/ifandfor',
    name: 'ifandfor',
    component: ifandfor
  },
  {
    path: '/watch',
    name: 'watchandwatchEffect',
    component: watchandwatchEffect
  },
  {
    path: '/keep-alive',
    name: 'keepAlive',
    component: keepAlive
  },
  {
    path: '/pinia',
    name: 'pinia',
    component: pinia
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
